<template>
  <div class="position">
    <!--    仓位列表弹窗-->
    <el-dialog
      v-dialogDrag
      :title="$t('menu.shipSpace')"
      model
      :visible.sync="isclientlDialog"
      :close-on-click-modal="false"
      width="60%"
      top="5vh"
      append-to-body
      :before-close="handleClose"
    >
      <div style="position: relative;margin-bottom: 15px">
        <search
          :options="selectData"
          :search-son="searchSon"
          :msg="tacitly"
          @seek="collect"
          @hand="clientSearch"
        />
        <el-button size="mini" style="margin-left: 450px;transform: translateY(20%);" type="primary" @click="clientSearch">{{ $t('btn.search') }}</el-button>
      </div>
      <jc-table
        :table-data="tableData"
        :table-header="clientDialogHeader"
        table-height="53vh"
        serial
        @clickRow="clientlSelectRow"
      >
        <!--        审核状态-->
        <template v-slot:btnState="col">
          <el-tag :type="col.scope.row.stateColor">{{ col.scope.row.fdocumentstatus }}</el-tag>
        </template>
        <!--        禁用状态-->
        <template v-slot:tagSlot="col">
          <el-tag v-if="col.scope.row.fforbidstatus === 'A'">{{ $t('market.normal') }}</el-tag>
          <el-tag v-else type="danger">{{ $t('btn.disab') }}<!--禁用--></el-tag>
        </template>
      </jc-table>
      <jc-pagination
        v-show="total > 0"
        :total="total"
        :page.sync="pageNum"
        :limit.sync="pageSize"
        @pagination="queryTBdCustomerList"
      />
    </el-dialog>
  </div>
</template>
<script>
import { queryWmsBdStockPosList } from '@/api/wms/stock'
import { toMxBmina } from '@/components/ToMxamineState'
import search from '@/components/Search'
import searData from '@/components/Search/mixin'

export default {
  components: {
    search
  },
  mixins: [searData],
  props: {
    msg: {
      type: [String, Number],
      default: ''
    },
    fsettleCurrId: {
      type: [String, Number],
      default: ''
    }
  },
  data() {
    return {
      ftype: 79,
      // 客户列表数据分页
      isclientlDialog: true,
      total: 0, // 总条目
      pageNum: 1, // 当前页
      pageSize: 200, // 每页显示多少条数据
      fname: '',
      tableData: [],
      clientDialogHeader: [
        { label: this.$t('market.stockname1'), prop: 'fname' },
        { label: this.$t('market.stockNumber1'), prop: 'fnumber' },
        { label: this.$t('market.warehouse'), prop: 'fstockName' },
        { label: this.$t('market.stocker'), prop: 'fstockerName' },
        { label: this.$t('market.address1'), prop: 'faddress' },
        { label: this.$t('market.documentstatus'), type: 'state', prop: 'fdocumentstatus' },
        { label: this.$t('market.forbidStatu'), type: 'tag', prop: 'fforbidstatus' }
      ],
      prodValue: {}
    }
  },
  created() {
    this.queryTBdCustomerList()
  },
  methods: {
    // 获取仓位列表
    async queryTBdCustomerList(ev) {
      this.details = []
      if (ev && !ev.page) {
        this.details = ev
      }
      const DATA = {
        fname: this.fname,
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        search: this.searCollData.concat(this.details)
      }
      const RES = await queryWmsBdStockPosList(DATA)
      this.tableData = RES.data.list
      this.tableData.map(item => {
        return toMxBmina(item)
      })
      this.total = RES.data.total
    },
    // 客户弹窗选中
    clientlSelectRow(item) {
      this.prodValue = item
      this.$emit('client', this.prodValue)
    },
    clientSearch(ev) {
      this.pageNum = 1
      if (ev && ev.fname) {
        this.searchSon = ev.detail
        this.queryTBdCustomerList(ev.detail)
      } else {
        this.queryTBdCustomerList()
      }
    },
    // 关闭前回调
    handleClose() {
      this.prodValue.isclientlDialog = false
      this.$emit('client', this.prodValue)
    }
  }
}
</script>

<style scoped lang="scss">
.position {
  @include listBom;
}
</style>
